<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
</head>

<body>
    <div id="app"></div>
    <script type="text/babel">
        class MyDom extends React.Component {
            myRef=React.createRef()

            constructor(props) {
                super(props)
                this.state = {
                    isHot: true
                }
            }
            change = () => {
                const { isHot } = this.state
                this.setState({
                    isHot:!isHot
                })
            }
            get=()=>{
                console.log(this.input1.value);
                console.log(this.myRef.current.value);
            }
            render() {
                return (
                    <div>
                        <input type="text" ref={c=>this.input1=c }/>
                        今天天气是{this.state.isHot ? '晴天' : '雨天'}
                        <input type="text" name="" id="" ref={this.myRef}/>
                        <button onClick={this.change}>按钮</button>
                        <button onClick={this.get}>按钮2</button>
                    </div>
                )
            }

        }


        ReactDOM.render(<MyDom />, document.getElementById('app'))
    </script>
</body>

</html>